<script setup>
import { ref } from "vue";
import Card from "../components/card.vue";
import CustomTabs from '../components/common/customTabs.vue'
import EChartsComponent from "../components/eChartsComponent.vue";

import usage from "@/assets/images/icon/icon_usage.png";
import downloadVolume from "@/assets/images/icon/icon_downloadVolume.png";
import userBase from "@/assets/images/icon/icon_userBase.png";
import pageViews from "@/assets/images/icon/icon_pageViews.png";

const cardList = ref([
  {
    title: "用户量",
    number: "2,000",
    icon: userBase,
    remarks: "总用户量",
    total: "120,000",
  },
  {
    title: "访问量",
    number: "20,000",
    icon: pageViews,
    remarks: "总访问量",
    total: "500,000",
  },
  {
    title: "下载量",
    number: "8,000",
    icon: downloadVolume,
    remarks: "总下载量",
    total: "120,000",
  },
  {
    title: "使用量",
    number: "5,000",
    icon: usage,
    remarks: "总使用量",
    total: "50,000",
  },
]);
const tabList = ref([
  {
    label: "流量趋势",
    name: "trend",
    option: {
      tooltip: {
        trigger: "axis",
        axisPointer: {
          type: "cross",
          label: {
            backgroundColor: "#6a7985",
          },
        },
      },
      legend: {
        data: ["Email", "Union Ads"],
      },
      toolbox: {
        feature: {
          saveAsImage: {},
        },
      },
      xAxis: [
        {
          type: "category",
          boundaryGap: false,
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
      ],
      yAxis: [
        {
          type: "value",
        },
      ],
      series: [
        {
          name: "Email",
          type: "line",
          stack: "Total",
          areaStyle: {},
          emphasis: {
            focus: "series",
          },
          data: [120, 132, 101, 134, 90, 230, 210],
        },
        {
          name: "Union Ads",
          type: "line",
          stack: "Total",
          areaStyle: {},
          emphasis: {
            focus: "series",
          },
          data: [220, 182, 191, 234, 290, 330, 310],
        },
      ],
    },
  },
  {
    label: "月访问量",
    name: "monthly",
    option: {
      xAxis: {
        type: "category",
        data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
      },
      yAxis: {
        type: "value",
      },
      series: [
        {
          data: [120, 200, 150, 80, 70, 110, 130],
          type: "bar",
        },
      ],
    },
  },
]);
const echarstList = ref([
  {
    title: "访问数量",
    option: {
      title: {
        text: "Basic Radar Chart",
      },
      legend: {
        data: ["Allocated Budget", "Actual Spending"],
      },
      radar: {
        // shape: 'circle',
        indicator: [
          { name: "Sales", max: 6500 },
          { name: "Administration", max: 16000 },
          { name: "Information Technology", max: 30000 },
          { name: "Customer Support", max: 38000 },
          { name: "Development", max: 52000 },
          { name: "Marketing", max: 25000 },
        ],
      },
      series: [
        {
          name: "Budget vs spending",
          type: "radar",
          data: [
            {
              value: [4200, 3000, 20000, 35000, 50000, 18000],
              name: "Allocated Budget",
            },
            {
              value: [5000, 14000, 28000, 26000, 42000, 21000],
              name: "Actual Spending",
            },
          ],
        },
      ],
    },
  },
  {
    title: "访问来源",
    option: {
      tooltip: {
        trigger: "item",
      },
      legend: {
        top: "5%",
        left: "center",
      },
      series: [
        {
          name: "Access From",
          type: "pie",
          radius: ["40%", "70%"],
          avoidLabelOverlap: false,
          itemStyle: {
            borderRadius: 10,
            borderColor: "#fff",
            borderWidth: 2,
          },
          label: {
            show: false,
            position: "center",
          },
          emphasis: {
            label: {
              show: true,
              fontSize: 40,
              fontWeight: "bold",
            },
          },
          labelLine: {
            show: false,
          },
          data: [
            { value: 1048, name: "Search Engine" },
            { value: 580, name: "Email" },
            { value: 484, name: "Union Ads" },
            { value: 300, name: "Video Ads" },
          ],
        },
      ],
    },
  },
  {
    title: "访问来源",
    option: {
      visualMap: {
        show: false,
        min: 80,
        max: 600,
        inRange: {
          colorLightness: [0, 1],
        },
      },
      series: [
        {
          name: "Access From",
          type: "pie",
          radius: "55%",
          center: ["50%", "50%"],
          data: [
            { value: 335, name: "Direct" },
            { value: 310, name: "Email" },
            { value: 274, name: "Union Ads" },
            { value: 235, name: "Video Ads" },
            { value: 400, name: "Search Engine" },
          ].sort(function (a, b) {
            return a.value - b.value;
          }),
          roseType: "radius",
          animationType: "scale",
        },
      ],
    },
  },
]);
</script>

<template>
  <div class="m-4">
    <el-row :gutter="15" class="mb-4">
      <el-col :span="6" v-for="(item, index) in cardList" :key="index">
        <Card :data="item" />
      </el-col>
    </el-row>

    <el-row class="mb-4">
      <el-col :span="24">
       <CustomTabs :tabs="tabList" />
      </el-col>
    </el-row>

    <el-row :gutter="15">
      <el-col :span="8" v-for="(item, index) in echarstList" :key="index">
        <Card :data="item" :hasContent="false">
          <EChartsComponent :option="item.option" />
        </Card>
      </el-col>
    </el-row>
  </div>
</template>

<style lang="scss" scoped></style>
